#include "Col.ph"
#ifdef __GNUG__
#pragma implementation
#endif

#include "Storage.h"
#include "MemBuf.h"

MemBuf::MemBuf(int sz, char *p, int cnt, bool alc) : StreamBuf(sz, p, cnt, alc)
{
}

int MemBuf::overflow(int c)
{
	if (c != EOF) {
		size_t pos= (size_t) (ptr-base);
		setbuf((char*)Storage::ReAlloc(base, pos*2), pos*2, 0, FALSE);
		ptr= base+pos;
		*ptr++= c;
	}
	return zapeof(c);
}

void MemBuf::SwitchToRead()
{
	gptr= ptr;
	ptr= base;
	fpos= 0;
}

long MemBuf::ContentsSize()
{
	return gptr-base;
}

